﻿using ctolua.Models.Enum;

namespace ctolua.Models.UI.control
{
    public class MCScrollView : Mui
    {
        public override EUi type { get => EUi.列表; set => base.type = EUi.列表; }
        public MCScrollView()
        {
        }

        public MCScrollView(string id) : base(id)
        {
        }

        public MCScrollView(MCScrollView u) : base(u)
        {
        }



        private string _text;
        /// <summary>
        /// 设置下拉框默认文本
        /// </summary>
        public string text
        {
            get => _text;
            set
            {
                game_api.set_combo_text(this.role, this.id, value);
                _text = value;
            }
        }



        /// <summary>
        /// 获取下拉框当前值
        /// </summary>
        public string value => game_api.get_combo_box_cur_value(this.id);

        private int? _margin;
        /// <summary>
        /// 设置ui列表组件间距
        /// </summary>
        public int? margin
        {
            get => _margin;
            set
            {
                if (value != null)
                {
                    game_api.set_ui_comp_margin(this.role, this.id, value);
                }

                _margin = value;
            }
        }

        /// <summary>
        /// 添加下拉框选项
        /// </summary>
        /// <param name="text">名称</param>
        /// <param name="value">值</param>
        public void add_combo_item(string text, string value)
        {
            game_api.add_combo_item(this.role, this.id, text, value);
        }
        /// <summary>
        /// 清空下拉框
        /// </summary>
        public void clear()
        {
            game_api.clear_combo_box(this.role, this.id);
        }
    }
}
